package com.allenjsl.springactuator.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/logger")
public class LogController {

    @Autowired
    private DiscoveryClient discoveryClient;

    /**
     * 测试日志等级
     * @return
     */
    @RequestMapping(value = "/loglevel" , method = {RequestMethod.GET})
    public String logLevel(){
        log.debug("debug log");
        log.info("info log");
        log.error("error log");
        return "success";
    }

    /**
     * 测试日志等级
     * @return
     */
    @RequestMapping(value = "/test",method = {RequestMethod.GET})
    public String logLevel(String name){
        return name;
    }

    /**
     * 获取所有服务
     */
    @RequestMapping(value = "/services",method = {RequestMethod.GET})
    public Object services() {
        return discoveryClient.getServices();
    }

    
}
